package com.yxch.admin.controller.user;

import com.yxch.admin.model.user.UserDTO;
import com.yxch.admin.model.user.UserMute;
import com.yxch.admin.service.user.UserService;
import com.yxch.admin.utils.ResultAPI;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理
 */
@Slf4j
@RestController
@RequestMapping("/yxch/admin/user")
public class UserController {
    @Autowired
    UserService userService;

    /**
     * 获取管理员信息
     *
     * @param token
     * @return
     */
    @GetMapping("/info")
    public ResultAPI getUserInfo(@RequestParam String token) {
        return userService.getUserInfo(token);
    }

    /**
     * 获取学生列表
     *
     * @param userDTO
     * @return
     */
    @GetMapping("/stu")
    public ResultAPI getStuInfo(UserDTO userDTO) {
        log.info("UserDTO{}", userDTO.toString());
        return userService.getStuInfo(userDTO);
    }

    /**
     * 获取学生列表
     *
     * @param userDTO
     * @return
     */
    @GetMapping("/teacher")
    public ResultAPI getTechInfo(UserDTO userDTO) {
        log.info("TeacherDTO{}", userDTO.toString());
        return userService.getTechInfo(userDTO);
    }

    /**
     * 用户id
     *
     * @param user_id
     * @return
     */
    @GetMapping("/mute")
    public ResultAPI getMuteInfo(@RequestParam Integer user_id) {
        log.info("user_id", user_id);
        return userService.getMuteInfo(user_id);
    }

    /**
     * 添加或更新禁言
     *
     * @param userMute
     * @return
     */
    @PostMapping("/mute")
    public ResultAPI AddandUpdateMuteUser(@RequestBody UserMute userMute) {
        return userService.AddandUpdateMuteUser(userMute);
    }
}
